#define DEBUG
#include <cstdio>

using namespace std;

const int maxlen=100000;

class Trie {
public:
  Trie *son[26];
  bool flag;

  Trie() {
    for (int i=0; i<26; i++) {
      son[i] = NULL;
    }
    flag = false;
  }

  Trie *down(char s) {
    if (!son[s-'a']) {
      son[s-'a'] = new Trie();
    }
    return son[s-'a'];
  }

  int search(char *s) {
    int ret=0;
    if (*s!='\0') {
      if (!son[*s-'a']) {
	son[*s-'a'] = new Trie();
      }
      ret += ret+!son[*s-'a']->flag;
      son[*s-'a']->flag = true;
      ret += son[*s-'a']->search(s+1);
    }
    return ret;
  }
};

int main() {
  freopen("password.in", "r", stdin);
  freopen("password.checker.out", "w", stdout);

  static char s[maxlen+1], t[maxlen+1];
  scanf("%s %s", s, t);

  Trie *trie = new Trie();

  long long ans=0;
  for (int i=0; s[i]!='\0'; i++) {
    trie = trie->down(s[i]);
    ans = ans+trie->search(t);
  }

  printf("%lld", ans);

  fclose(stdin);
  fclose(stdout);
  return 0;
}
